package com.supervision.student;

import java.net.URL;

import okhttp3.OkHttpClient;
import okhttp3.Request;

public class SOSThread extends Thread {
    String phone;   //学生手机
    String webIp;   //服务器ip地址

    public SOSThread(String phone, String webIp) {
        this.phone = phone;
        this.webIp = webIp;
    }

    @Override
    public void run() {
        OkHttpClient okHttpClient = new OkHttpClient();//创建单例
        URL url;
        Request request;//创建请求
        try {
            //设置url
            url = new URL("http://" + webIp + ":8080/setSOS/" + phone);
            //设置请求
            request = new Request.Builder()
                    .url(url)
                    .build();
            //执行请求
            okHttpClient.newCall(request).execute();
        }  catch (Exception e) {
            e.printStackTrace();
        }
    }
}

